package com.ctg.behavior.calc.impala.transfer.usergroups;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.ctg.behavior.calc.common.CtSQLParam;
import com.ctg.behavior.calc.impala.transfer.CtFilterTransfer;
import com.ctg.behavior.common.calc.CtCalc;
import com.ctg.behavior.common.calc.CtCalcFilter;
import com.ctg.behavior.common.usergroups.CtUGUserPropertyRule;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class CtUGUPRuleTransfer extends CtFilterTransfer {

	/******************************************************
	 * @apiNote:
	 */
	@Override
	public String doTransfer(CtCalc calcObject, CtSQLParam sqlParam) {
		
		if (!(calcObject instanceof CtUGUserPropertyRule)) {
			log.warn("calcObject is not CtUGUserPropertyRule, class={}", calcObject.getClass());
			log.warn("calcObject: {}", JSON.toJSON(calcObject));
			return "";
		}
		
		CtCalcFilter calcFilter = (CtCalcFilter) calcObject;
		log.info("CalcBody={}", JSON.toJSONString(calcFilter));
		
		String impalaSQL = super.doTransfer(calcFilter, sqlParam);
		log.info("CalcSQL={}", impalaSQL);
		
		return impalaSQL;
	}

}
